package com.ruoyi.wx.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wx.mapper.OrdersMapper;
import com.ruoyi.wx.domain.Orders;
import com.ruoyi.wx.service.IOrdersService;

/**
 * 订单信息Service业务层处理
 *
 * @author hxie
 * @date 2021-01-07
 */
@Service
public class OrdersServiceImpl implements IOrdersService
{
    @Autowired
    private OrdersMapper ordersMapper;

    /**
     * 查询订单信息
     *
     * @param ordersId 订单信息ID
     * @return 订单信息
     */
    @Override
    public Orders selectOrdersById(String ordersId)
    {
        return ordersMapper.selectOrdersById(ordersId);
    }

    /**
     * 查询订单信息列表
     *
     * @param orders 订单信息
     * @return 订单信息
     */
    @Override
    public List<Orders> selectOrdersList(Orders orders)
    {
        return ordersMapper.selectOrdersList(orders);
    }

    /**
     * 新增订单信息
     *
     * @param orders 订单信息
     * @return 结果
     */
    @Override
    public int insertOrders(Orders orders)
    {
        orders.setCreateTime(DateUtils.getNowDate());
        return ordersMapper.insertOrders(orders);
    }

    /**
     * 修改订单信息
     *
     * @param orders 订单信息
     * @return 结果
     */
    @Override
    public int updateOrders(Orders orders)
    {
        orders.setUpdateTime(DateUtils.getNowDate());
        return ordersMapper.updateOrders(orders);
    }

    /**
     * 批量删除订单信息
     *
     * @param ordersIds 需要删除的订单信息ID
     * @return 结果
     */
    @Override
    public int deleteOrdersByIds(String[] ordersIds)
    {
        return ordersMapper.deleteOrdersByIds(ordersIds);
    }

    /**
     * 删除订单信息信息
     *
     * @param ordersId 订单信息ID
     * @return 结果
     */
    @Override
    public int deleteOrdersById(String ordersId)
    {
        return ordersMapper.deleteOrdersById(ordersId);
    }

    /**
     * 查询用户所有订单信息
     */
    @Override
    public List<Orders> findAllOrder(String weixinOpenid){
        return ordersMapper.findAllOrder(weixinOpenid);
    }

    /**
     * 获取当前用户当前订单详情
     */
    @Override
    public Orders selectnoworder(String weixinOpenid){
        int ordersId=ordersMapper.selectnoworderid(weixinOpenid);
        return ordersMapper.selectOrdersById(Integer.toString(ordersId));
    }

}
